package silo.dungeonbuddy;

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.Vector;

public class Square extends SelectableItem
{
	private int x;
	private int y;
	private boolean obstructed;
	private Vector occupees = new Vector();
	private Vector terrain = new Vector();
	private int row;
	private int column;
	private boolean selected;
	private Start game;
	//TODO: Terrain stuff
	
	public Square(String eName, Start eGame, int x, int y, boolean obs, int row, int column)
	{
		super(eName);
		this.x = x;
		this.y = y;
		obstructed = obs;
		this.row=row;
		this.column=column;
		selected=false;
		game=eGame;
		occupees = new Vector();
		terrain = new Vector();
	}//constructor
	
	public void draw(Graphics2D g)
	{
		/*if((selected)&&((x+1+game.getOffsetX())<(int)Math.floor(game.getWidth()*0.75)))
		{
			g.setColor(Color.yellow);
			g.fillRect(((x/(game.getHeight()/20))*(game.getHeight()/game.getSquaresPerScreen()))+1+game.getOffsetX(),((y/(game.getHeight()/20))*(game.getHeight()/game.getSquaresPerScreen()))+1+game.getOffsetY(),(int)Math.floor(game.getHeight()/game.getSquaresPerScreen())-1,(int)Math.floor(game.getHeight()/game.getSquaresPerScreen())-1);
		}*/
		if(selected)
		{
			g.setColor(Color.yellow);
			g.fillRect(((x/(game.getHeight()/20))*(game.getHeight()/game.getSquaresPerScreen()))+1+game.getOffsetX().getValue(),((y/(game.getHeight()/20))*(game.getHeight()/game.getSquaresPerScreen()))+1+game.getOffsetY().getValue(),(int)Math.floor(game.getHeight()/game.getSquaresPerScreen())-1,(int)Math.floor(game.getHeight()/game.getSquaresPerScreen())-1);
		}
	}//draw
	
	public void draw(Graphics2D g, MapForm sender)
	{
		if(selected)
		{
			g.setColor(Color.yellow);
			g.fillRect(((x/(sender.getHeight()/20))*(sender.getHeight()/sender.getSquaresPerScreen()))+1+sender.getOffsetX().getValue(),((y/(sender.getHeight()/20))*(sender.getHeight()/sender.getSquaresPerScreen()))+1+sender.getOffsetY().getValue(),(int)Math.floor(sender.getHeight()/sender.getSquaresPerScreen())-1,(int)Math.floor(sender.getHeight()/sender.getSquaresPerScreen())-1);
		}
	}//draw
	
	//GETTERS
	public int getX()
	{
		return x;
	}
	public int getY()
	{
		return y;
	}
	public boolean getObstructed()
	{
		return obstructed;
	}
	public Vector getOccupees()
	{
		return occupees;
	}
	public Vector getTerrain()
	{
		return terrain;
	}
	public int getRow()
	{
		return row;
	}
	public int getColumn()
	{
		return column;
	}
	public boolean getSelected()
	{
		return selected;
	}
	
	//SETTERS
	public void setX(int eX)
	{
		x=eX;
	}
	public void setY(int eY)
	{
		y=eY;
	}
	public void setObstructed(boolean eObs)
	{
		obstructed = eObs;
	}
	public void setOccupees(Vector eOcc)
	{
		occupees = eOcc;
	}
	public void setTerrain(Vector eTerr)
	{
		terrain = eTerr;
	}
	public void setRow(int eRow)
	{
		row=eRow;
	}
	public void setColumn(int eColumn)
	{
		column=eColumn;
	}
	public void setSelected(boolean eSel)
	{
		selected=eSel;
	}
}//class Square